MV_XML_GetGenICamXML

MV_XML_GetGenICamXML

Get the camera description file in XML format.

API Definition

int MV_XML_GetGenICamXML(
  void               *handle,
  unsigned char      *pData,
  unsigned int       nDataSize,
  unsigned int       *pnDataLen
);

Parameters

handle

[IN] Device handle, which is returned by MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.

pData

[IN][OUT] The XML file buffer address

nDataSize

[IN] The XML file buffer size

pnDataLen

[OUT] The XML file length

Return Value

Return MV_OK(0) on success, and return Error Code on failure.

Remarks

  • When pData is NULL or when the value of nDataSize is larger than the actual XML file size, no data will be copied, and the XML file size is returned by pnDataLen.

  • When pData is valid and the buffer size is enough, the complete data will be copied and stored in the buffer, and the XML file size is returned by pnDataLen.

The following sample code is for reference only.

#include "MvCameraControl.h"

#define MAX_XML_FILE_SIZE       (1024*1024*3)

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;  
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //Other process... 

    unsigned char* pXMLBuf = (unsigned char*)malloc(MAX_XML_FILE_SIZE);
    if (NULL == pXMLBuf)
    {
        printf("error: malloc xml buffer failed!\n");
        break;
    }

   unsigned int nXMLDataLen = 0;
   nRet = MV_XML_GetGenICamXML(m_handle, pXMLBuf, MAX_XML_FILE_SIZE, &nXMLDataLen);
   if (MV_OK != nRet || nXMLDataLen > MAX_XML_FILE_SIZE)
   {
        printf("error: GetGenICamXML failed! [%x]\n", nRet);
        break;
   }

    //Other process...

    //Shut down device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

MV_XML_GetGenICamXML

Get the camera description file in XML format.

API Definition

int MV_XML_GetGenICamXML(
  void               *handle,
  unsigned char      *pData,
  unsigned int       nDataSize,
  unsigned int       *pnDataLen
);

Parameters

handle

[IN] Device handle, which is returned by MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.

pData

[IN][OUT] The XML file buffer address

nDataSize

[IN] The XML file buffer size

pnDataLen

[OUT] The XML file length

Return Value

Return MV_OK(0) on success, and return Error Code on failure.

Remarks

  • When pData is NULL or when the value of nDataSize is larger than the actual XML file size, no data will be copied, and the XML file size is returned by pnDataLen.

  • When pData is valid and the buffer size is enough, the complete data will be copied and stored in the buffer, and the XML file size is returned by pnDataLen.

The following sample code is for reference only.

#include "MvCameraControl.h"

#define MAX_XML_FILE_SIZE       (1024*1024*3)

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;  
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //Other process... 

    unsigned char* pXMLBuf = (unsigned char*)malloc(MAX_XML_FILE_SIZE);
    if (NULL == pXMLBuf)
    {
        printf("error: malloc xml buffer failed!\n");
        break;
    }

   unsigned int nXMLDataLen = 0;
   nRet = MV_XML_GetGenICamXML(m_handle, pXMLBuf, MAX_XML_FILE_SIZE, &nXMLDataLen);
   if (MV_OK != nRet || nXMLDataLen > MAX_XML_FILE_SIZE)
   {
        printf("error: GetGenICamXML failed! [%x]\n", nRet);
        break;
   }

    //Other process...

    //Shut down device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}